<template>
  <div id="app">
     <h2>我的年龄：{{age}}</h2>
     <h2>ta的年龄：{{$store.getters.getAge}}</h2>
     <button @click="$store.state.age+=10"></button>
     <button @click="changeAge(5)">同步+</button>
      <button @click="$store.dispatch('changeAge')">异步+</button>
  </div>
</template>

<script>
import {mapState,mapGetters,mapMutations} from './vuex';

export default {
    computed: {
        ...mapState(['age']),
        // age(){
        //     return this.$store.state.age
        // },
        ...mapGetters(['getAge']),
        // getAge(){
        //     return this.$store.getters.getAge
        // }
    },
    methods:{
        ...mapMutations(['changeAge']),
        // changeAge(payload){
        //     this.$store.commit('changeAge',payload);
        // }
    },
    mounted(){
        console.log(this,'vvvv')
    }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
